-
Notifications
You must be signed in to change notification settings - Fork 343
feat(genai)!: migration to google-genai
#1330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
SDK handles this internally for both Gemini and Vertex
it's inherited from `_BaseGoogleGenerativeAI` already
`client_options` is no longer supported; we add it as an alias to `base_url` and will warn if any key other than `'api_endpoint'` is used
google-genaigoogle-genai
google-genaigoogle-genai
google-genaigoogle-genai
| return configs | ||
|
|
||
|
|
||
| # Dynamically create test classes for each backend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid this complication, for Vertex I'd be OK re-implementing tests on a fast model and running them on release + a schedule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the langchain-google-genai package from using google-ai-generativelanguage to the newer google-genai SDK. This is a major infrastructure change that modernizes the integration with Google's Generative AI APIs.
Key Changes:
- Migrates from
google-ai-generativelanguageprotobuf-based SDK togoogle-genaiPydantic-based SDK - Updates all imports from
google.ai.generativelanguagetogoogle.genai.types - Removes transport-related parameters (
client_options,transport) in favor of HTTP-based configuration - Adds comprehensive test coverage for new SDK features
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
libs/genai/uv.lock |
Updates dependency lock file with new google-genai package and updated transitive dependencies |
libs/genai/pyproject.toml |
Adds google-genai>=1.52.0,<2.0.0 as a core dependency |
libs/genai/tests/unit_tests/test_standard.py |
Updates tests for new SDK, adds API key parameter |
libs/genai/tests/unit_tests/test_llms.py |
Migrates from GAPIC client mocking to new SDK client mocking |
libs/genai/tests/unit_tests/test_imports.py |
Adds create_context_cache to expected imports |
libs/genai/tests/unit_tests/test_function_utils.py |
Comprehensive updates for Pydantic-based type system |
libs/genai/tests/unit_tests/test_common.py |
Reorganizes test ordering |
libs/genai/tests/unit_tests/test_chat_models_protobuf_fix.py |
Deleted (tests moved to main test file) |
libs/genai/tests/unit_tests/test_chat_models.py |
Major refactoring for new SDK, adds extensive new tests |
libs/genai/tests/unit_tests/__snapshots__/test_standard.ambr |
Updates model name format snapshot |
libs/genai/tests/integration_tests/test_llms.py |
Adds proper client cleanup in async tests |
libs/genai/tests/integration_tests/test_builtin_tools.py |
Deleted (functionality removed/relocated) |
libs/genai/tests/conftest.py |
Adds backend configuration fixtures for testing both Google AI and Vertex AI |
libs/genai/langchain_google_genai/llms.py |
Removes client_options parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| or "gemini-1.5-flash" in self.model | ||
| or "gemini-2" in self.model | ||
| ) | ||
| return self.profile.get("tool_choice", True) if self.profile else True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
want to flag that we default to True
| tool_call_chunks = [] | ||
| for part in response_candidate.content.parts: | ||
|
|
||
| parts = response_candidate.content.parts or [] if response_candidate.content else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in what situation is it not under parts?
| populate_by_name=True, | ||
| ) | ||
|
|
||
| @property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to keep?
Based largely on the excellent foundational work done by @emhagman in #1077
TODO
_ALLOWED_SCHEMA_FIELDS_SET)https://googleapis.github.io/python-genai/index.html
Closes #853
Closes #1212
Closes #1265
Closes #1360
Closes #1362
Closes #1366
Closes #1367
Closes #1376
Closes #1409